package com.mr.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mr.model.Point;
import com.mr.web.support.PageUtil;

@Controller
public class UserController extends AnnotationController {
	
	@RequestMapping("/auth/member/user/pointList.xhtml")
	public String userList(Long memberid, Integer pageNo, HttpServletRequest req, ModelMap model){
		if(pageNo==null) pageNo = 0;
		Integer limit = 15;
		Integer count = commonService.getPointCount(memberid);
		List<Point> pointList = commonService.getPointList(memberid, pageNo*limit, limit);
		
		Integer rowsPerPage = limit;
		PageUtil pageUtil = new PageUtil(count, rowsPerPage, pageNo, "auth/member/user/pointList.xhtml");
		Map params = new HashMap();
		params.put("memberid", memberid+"");
		pageUtil.initPageInfo(params);
		model.put("pageUtil", pageUtil);
		
		model.put("pointList", pointList);
		model.put("count", count);
		return "user/pointList.vm";
	}
}
